<html>
<head><meta charset="utf-8"><title>Can proc-macros define new crates? · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html">Can proc-macros define new crates?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="226988402"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/226988402" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#226988402">(Feb 19 2021 at 16:24)</a>:</h4>
<p>Is it possible for this code:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="n">cross_crate</span><span class="o">!</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">  </span><span class="sd">/// Some docs</span>
<span class="w">  </span><span class="k">pub</span><span class="w"> </span><span class="k">struct</span> <span class="nc">S</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>to define <code>S</code> in a different crate and re-export it at the callsite of the macro? I don't know if spans can affect the crate or only the edition.</p>
<p>Context: a version of <a href="https://github.com/rust-lang/rust/pull/82295">https://github.com/rust-lang/rust/pull/82295</a> only checks things in the current crate, and I have a really bad feeling some enterprising library author (<em>cough</em> <span class="user-mention" data-user-id="232018">@Daniel Henry-Mantilla</span> <em>cough</em>) will write a library to exploit the loophole</p>



<a name="226988449"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/226988449" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#226988449">(Feb 19 2021 at 16:24)</a>:</h4>
<p>cc <span class="user-mention" data-user-id="116122">@simulacrum</span></p>



<a name="226988538"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/226988538" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#226988538">(Feb 19 2021 at 16:24)</a>:</h4>
<p>I'm not sure I follow the question.</p>



<a name="226988557"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/226988557" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#226988557">(Feb 19 2021 at 16:24)</a>:</h4>
<p>No macro can define a crate.</p>



<a name="226988599"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/226988599" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#226988599">(Feb 19 2021 at 16:25)</a>:</h4>
<p>that was my question, thanks :)</p>



<a name="226988612"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/226988612" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#226988612">(Feb 19 2021 at 16:25)</a>:</h4>
<p>(like, crates are not a concept within the language)</p>



<a name="226988649"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/226988649" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#226988649">(Feb 19 2021 at 16:25)</a>:</h4>
<p>they're the compilation unit, macros expand to rust code</p>



<a name="226988676"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/226988676" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#226988676">(Feb 19 2021 at 16:25)</a>:</h4>
<p>you can't define crates "within" rust code</p>



<a name="226988783"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/226988783" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#226988783">(Feb 19 2021 at 16:26)</a>:</h4>
<p>and I'm not sure what you mean by defining S in a different crate and re-exporting it at the callsite of the macro; what do you mean by "defining it"?</p>



<a name="226988816"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/226988816" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#226988816">(Feb 19 2021 at 16:26)</a>:</h4>
<p>you can certainly assign a span from some other crate (including edition, and other relevant details)</p>



<a name="226988897"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/226988897" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#226988897">(Feb 19 2021 at 16:27)</a>:</h4>
<p>You could write out crate contents, build them transparently, and expand to <code>extern crate</code>?</p>



<a name="226988935"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/226988935" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#226988935">(Feb 19 2021 at 16:27)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116122">simulacrum</span> <a href="#narrow/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F/near/226988783">said</a>:</p>
<blockquote>
<p>and I'm not sure what you mean by defining S in a different crate and re-exporting it at the callsite of the macro; what do you mean by "defining it"?</p>
</blockquote>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="c1">// crate1</span>
<span class="sd">/// [*const::to_raw_parts]</span>
<span class="k">struct</span> <span class="nc">S</span><span class="p">;</span><span class="w"></span>

<span class="c1">// crate2</span>
<span class="k">pub</span><span class="w"> </span><span class="k">use</span><span class="w"> </span><span class="n">crate1</span>::<span class="n">S</span><span class="p">;</span><span class="w"></span>
</code></pre></div>



<a name="226988959"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/226988959" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#226988959">(Feb 19 2021 at 16:27)</a>:</h4>
<p><span class="user-mention silent" data-user-id="123586">nagisa</span> <a href="#narrow/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F/near/226988897">said</a>:</p>
<blockquote>
<p>You could write out crate contents, build them transparently, and expand to <code>extern crate</code>?</p>
</blockquote>
<p>yeah this sort of evil genius is exactly what I'm talking about <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span></p>



<a name="226988973"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/226988973" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#226988973">(Feb 19 2021 at 16:27)</a>:</h4>
<p>I mean you <em>can</em></p>



<a name="226989019"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/226989019" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#226989019">(Feb 19 2021 at 16:27)</a>:</h4>
<p>I sort of "don't care" personally, if folks want to break stability they'll likely find a way</p>



<a name="226989073"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/226989073" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#226989073">(Feb 19 2021 at 16:28)</a>:</h4>
<p>you could also rustc_bootstrap that compilation if you wanted to</p>



<a name="226989129"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/226989129" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#226989129">(Feb 19 2021 at 16:28)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116122">simulacrum</span> <a href="#narrow/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F/near/226989019">said</a>:</p>
<blockquote>
<p>I sort of "don't care" personally, if folks want to break stability they'll likely find a way</p>
</blockquote>
<p>I do really care though :/ this feature is <em>broken</em>, that's why it's feature gated in the first place</p>



<a name="226989149"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/226989149" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#226989149">(Feb 19 2021 at 16:28)</a>:</h4>
<p>and the feature being broken hasn't stopped people from using it in the past</p>



<a name="226989166"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/226989166" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#226989166">(Feb 19 2021 at 16:28)</a>:</h4>
<p>for <a href="https://github.com/rust-lang/rust/issues/82295">#82295</a> specifically it doesn't seem worth the complexity to try to re-check features on used re-exports</p>



<a name="226989265"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/226989265" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#226989265">(Feb 19 2021 at 16:29)</a>:</h4>
<p>I'm not arguing against it being feature gated? that seems good; I'm just saying that re-exports don't seem like the place to attack that</p>



<a name="226989485"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/226989485" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#226989485">(Feb 19 2021 at 16:31)</a>:</h4>
<p>my principle is that we should keep feature gates to local checks</p>



<a name="226989521"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/226989521" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#226989521">(Feb 19 2021 at 16:31)</a>:</h4>
<p>it's just been my experience that any time people can exploit the implementation, they do :/</p>



<a name="226989540"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/226989540" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#226989540">(Feb 19 2021 at 16:31)</a>:</h4>
<p>ok? I guess I don't see that as a problem</p>



<a name="226989569"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/226989569" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#226989569">(Feb 19 2021 at 16:31)</a>:</h4>
<p>i.e., they can exploit it, we can also break those exploits arbitrarily</p>



<a name="226989589"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/226989589" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#226989589">(Feb 19 2021 at 16:31)</a>:</h4>
<p>they're not going to do so accidentally in a way where they get broken most likely</p>



<a name="226989721"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/226989721" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#226989721">(Feb 19 2021 at 16:32)</a>:</h4>
<p>since presumably few people write docs without rendering them locally (or without ci running rustdoc)</p>



<a name="226989838"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/226989838" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#226989838">(Feb 19 2021 at 16:33)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116122">simulacrum</span> <a href="#narrow/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F/near/226989721">said</a>:</p>
<blockquote>
<p>since presumably few people write docs without rendering them locally (or without ci running rustdoc)</p>
</blockquote>
<p>you'd be surprised <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span> a lot of people show up in #docs-rs wanting us to publish a "doc only" change because they haven't ever tried to document their crate before</p>



<a name="226989963"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/226989963" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#226989963">(Feb 19 2021 at 16:34)</a>:</h4>
<p>interesting; but still, those people aren't directly exposed to instability in some sense</p>



<a name="226990084"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/226990084" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#226990084">(Feb 19 2021 at 16:35)</a>:</h4>
<p>I mean, I don't really have the energy to keep arguing about it so I can revert, but I still don't like it :/</p>



<a name="226990256"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/226990256" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#226990256">(Feb 19 2021 at 16:36)</a>:</h4>
<p>I guess I'm not sure I understand</p>



<a name="226990363"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/226990363" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#226990363">(Feb 19 2021 at 16:36)</a>:</h4>
<p>I'm saying we shouldn't check <em>at all</em> on the local crate, when it's using a re-export</p>



<a name="226990400"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/226990400" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#226990400">(Feb 19 2021 at 16:36)</a>:</h4>
<p>that seems like it solves the issue and is to some extent compatible with your suggestion?</p>



<a name="226990471"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/226990471" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#226990471">(Feb 19 2021 at 16:37)</a>:</h4>
<p>it still allows bypassing the feature gate by putting the item in another crate, though</p>



<a name="226990497"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/226990497" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#226990497">(Feb 19 2021 at 16:37)</a>:</h4>
<p>i.e., we could extend later to feature checking the upstream crate as well, but I'd prefer that we do so in a less ad-hoc manner, e.g., store features in metadata rather than iterating attributes</p>



<a name="226990547"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/226990547" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#226990547">(Feb 19 2021 at 16:37)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116122">simulacrum</span> <a href="#narrow/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F/near/226990497">said</a>:</p>
<blockquote>
<p>i.e., we could extend later to feature checking the upstream crate as well, but I'd prefer that we do so in a less ad-hoc manner, e.g., store features in metadata rather than iterating attributes</p>
</blockquote>
<p>ok, I would like that :)</p>



<a name="226990565"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/226990565" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#226990565">(Feb 19 2021 at 16:37)</a>:</h4>
<p>and revert this just for now</p>



<a name="226990644"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/226990644" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#226990644">(Feb 19 2021 at 16:38)</a>:</h4>
<p>I'm primarily against the ad-hoc feature checking in the PR as-is</p>



<a name="226990685"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/226990685" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#226990685">(Feb 19 2021 at 16:38)</a>:</h4>
<p>I think the <em>principle</em> of double checking our work in some sense also feels flawed</p>



<a name="226990731"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/226990731" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#226990731">(Feb 19 2021 at 16:38)</a>:</h4>
<p>in some sense I'd say that either a) we should "trust" upstream or b) we should ask for the feature gate locally</p>



<a name="226990807"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/226990807" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#226990807">(Feb 19 2021 at 16:39)</a>:</h4>
<p>I'm worried in particular that checking upstream is going to be a never-ending battle</p>



<a name="226996967"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/226996967" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Henry-Mantilla <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#226996967">(Feb 19 2021 at 17:19)</a>:</h4>
<p><span class="user-mention" data-user-id="232545">@Joshua Nelson</span> the most cursed thing I have seen in this fashion is <a href="https://lib.rs/crates/inline-proc">https://lib.rs/crates/inline-proc</a>; and I believe that crate does not truly bring an external crate into the current compilation; instead, it does compile that other thing within the fs, and then a proc-macro comes and loads and executes that compiled code #scary. If there was a way for a macro to inject an external crate within the compilation process I believe that crate would be using that <span aria-label="upside down" class="emoji emoji-1f643" role="img" title="upside down">:upside_down:</span></p>



<a name="227011358"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/227011358" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#227011358">(Feb 19 2021 at 19:03)</a>:</h4>
<p>yeah i write docs constantly and rarely render them locally</p>



<a name="227011729"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/227011729" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#227011729">(Feb 19 2021 at 19:06)</a>:</h4>
<p><span class="user-mention silent" data-user-id="224471">Lokathor</span> <a href="#narrow/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F/near/227011358">said</a>:</p>
<blockquote>
<p>yeah i write docs constantly and rarely render them locally</p>
</blockquote>
<p>This seems "normal" to me; writing docs with the intent to not render them at all for the local crate seems not normal though :)</p>



<a name="227012769"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/227012769" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#227012769">(Feb 19 2021 at 19:12)</a>:</h4>
<p>well notably i write docs so that RA tooltips work, and where it differs from how rustdoc works i have to go with ra style</p>



<a name="227032227"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/227032227" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#227032227">(Feb 19 2021 at 21:37)</a>:</h4>
<p>Conversely, I wish that docs had hot-reloading sometimes. Then I'd open it on one monitor and edit on the other.</p>



<a name="227032411"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/227032411" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#227032411">(Feb 19 2021 at 21:39)</a>:</h4>
<p>You could set that up with <code>cargo watch</code> I think</p>



<a name="227038055"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/227038055" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#227038055">(Feb 19 2021 at 22:14)</a>:</h4>
<p><code>cargo watch -c -x doc</code></p>



<a name="227051113"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/227051113" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#227051113">(Feb 20 2021 at 00:33)</a>:</h4>
<p>I'm not sure y'all have used hot reloading before, as that doesn't solve what I mean :-)</p>



<a name="227051939"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/227051939" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#227051939">(Feb 20 2021 at 00:44)</a>:</h4>
<p>I've done live code hotloading before</p>



<a name="227051972"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/227051972" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#227051972">(Feb 20 2021 at 00:45)</a>:</h4>
<p>but in the context of rustdoc i can't imagine it meaning anything other than "run rustdoc again when the files on disk change"</p>



<a name="227052019"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/227052019" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#227052019">(Feb 20 2021 at 00:45)</a>:</h4>
<p>i mean the browser doesn't also referesh, but eh</p>



<a name="227052068"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/227052068" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#227052068">(Feb 20 2021 at 00:46)</a>:</h4>
<p><code>mdbook</code> actually can also have the browser refresh, which is nifty</p>



<a name="227052087"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/227052087" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#227052087">(Feb 20 2021 at 00:46)</a>:</h4>
<p>teach rustdoc a thing</p>



<a name="227052125"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/227052125" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#227052125">(Feb 20 2021 at 00:46)</a>:</h4>
<p>Yes, the browser refresh is the meaningful part for me. Staying at the same (rough) location.</p>



<a name="227052407"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/227052407" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#227052407">(Feb 20 2021 at 00:50)</a>:</h4>
<p>eh, just tapping F5 usually works :P</p>



<a name="227054110"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/227054110" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#227054110">(Feb 20 2021 at 01:15)</a>:</h4>
<p>As does typing each letter of <code>cargo doc</code>, but you suggest <code>cargo watch</code> instead...</p>



<a name="227054356"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/227054356" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#227054356">(Feb 20 2021 at 01:19)</a>:</h4>
<p><span class="user-mention" data-user-id="116155">@Jake Goulding</span> you can probably hack it with <code>--html-after-content</code> somehow</p>



<a name="227054366"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/227054366" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#227054366">(Feb 20 2021 at 01:19)</a>:</h4>
<p>I think this would be better as some sort of plugin than in rustdoc itself</p>



<a name="227054414"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/227054414" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#227054414">(Feb 20 2021 at 01:20)</a>:</h4>
<p>That does seem plausible. For all I know, someone has done it already; I've not searched at all.</p>



<a name="227058901"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/227058901" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Andrea Nall <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#227058901">(Feb 20 2021 at 02:38)</a>:</h4>
<p>the suggested <code>cargo watch</code>+ <a href="https://github.com/tapio/live-server">https://github.com/tapio/live-server</a> might work?</p>



<a name="227059341"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/227059341" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#227059341">(Feb 20 2021 at 02:47)</a>:</h4>
<p>interesting; I usually just serve it from the filesystem, but a smartererer webserver could also do the trick!</p>



<a name="227059357"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/227059357" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#227059357">(Feb 20 2021 at 02:48)</a>:</h4>
<p>It's funny because the cargo watch part I'm :meh: about — I've keyboard commands for generating the docs when I get to a part where I want to see it</p>



<a name="227059812"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/227059812" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Andrea Nall <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#227059812">(Feb 20 2021 at 02:55)</a>:</h4>
<p>as long as the file changes, that should pick it up</p>



<a name="227059826"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20proc-macros%20define%20new%20crates%3F/near/227059826" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Andrea Nall <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20proc-macros.20define.20new.20crates.3F.html#227059826">(Feb 20 2021 at 02:55)</a>:</h4>
<p>so you should be able to do your keyboard command and then have live-server pick it up and reload the page</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>